﻿using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using ProjectN.Core.Instance.Data;

namespace ProjectN.Core.Element
{
    static partial class Utilities
    {
        public static Brush ColoredBrush(Brush origin, Color? color)
        {
            if (color.HasValue)
                return new SolidBrush(color.Value);
            else
                return origin;
        }
    }
    public class Path : BasicElement
    {
        protected Pen border;
        protected Brush? fill;
        protected GraphicsPath path;
        public Path(GraphicsPath path, Pen border, Brush? fill = null)
        {
            this.border = border;
            this.fill = fill;
            this.path = path;
            this.Draw += Path_Draw;
        }

        protected override void UpdateData(InstanceData data) { }

        private void Path_Draw(object sender, DrawEventArgs e)
        {
            if (this.fill != null)
                e.Graphics.FillPath(Utilities.ColoredBrush(fill, e.Color), path);
            e.Graphics.DrawPath(Utilities.ColoredPen(border, e.Color), path);
        }

    }
}
